clear all
use "DruckmanetalCOVID.dta"

**DEPENDENT VARIABLES
**Worry
replace pubhealthworry=(pubhealthworry-1)/3
replace econmyworry=(econmyworry-1)/3
replace educationworry=(educationworry-1)/3 
replace socialworry=(socialworry-1)/3 
replace entertworry=(entertworry-1)/3 
replace electionworry=(electionworry-1)/3 
replace persphyheaworry=(persphyheaworry-1)/3 
replace persmentheaworry=(persmentheaworry-1)/3 
replace persfinworry=(persfinworry-1)/3 
replace perseducworry=(perseducworry-1)/3 
replace persfriendworry=(persfriendworry-1)/3 
replace pershobbyworry=(pershobbyworry-1)/3

alpha pubhealthworry econmyworry educationworry socialworry entertworry electionworry persphyheaworry persmentheaworry persfinworry perseducworry persfriendworry pershobbyworry
gen worry=(pubhealthworry +econmyworry +educationworry +socialworry +entertworry +electionworry +persphyheaworry +persmentheaworry +persfinworry +perseducworry +persfriendworry +pershobbyworry)/12

**Behavior
gen covidbehavior = wash + workhome + handsan + canceltrave + avoid10 + feet + facemask + gloves + nostore + delivery + cooked + lessoutside + allhome + extfood 

gen covidbehavioreasy = wash + handsan + avoid10 + feet + facemask + gloves + cooked + lessoutside 
gen covidbehaviorhard = workhome + canceltrave + nostore + delivery + allhome + extfood 


alpha wash handsan avoid10 feet facemask gloves cooked lessoutside

alpha wash workhome handsan canceltrave avoid10 feet facemask gloves nostore delivery cooked lessoutside allhome extfood 

**Policy
gen flipliftstayhome = 5-liftstayhome

replace closebusin=(closebusin-1)/3
replace flipliftstayhome=(flipliftstayhome-1)/3
replace fines=(fines-1)/3

gen covidpolicy=(closebusin +flipliftstayhome +fines)/3


**MAIN INDEPENDENT VARIABLES
**PARTISANSHIP AND POLARIZATION AND CASES
gen republican=wave2pid
recode republican 1=0 2=0 3=0 4=. 5=1 6=1 7=1

gen pid3=wave2pid
recode pid3 1=0 2=0 3=0 4=1 5=2 6=2 7=2
label define pid3lab 0 "Democrat" 1 "Pure Independent" 2 "Republican"
label values pid3 pid3lab

gen w2pidx=abs(wave2pid-4)

gen strp2=w2pidx
recode strp2 0=. 1=0 2=0 3=1

gen negparty = (1-allout) if condition2 != 13

gen negcat=negparty
recode negcat 0/.3=0 .3000000001/.6999999999999=1 .7/1=2

gen polarization=allin-allout if condition2!=13
recode polarization -1/0=0


gen casespercapita = day3_avg_cases/(countypop/1000)

gen countypopmil=countypop/1000000

gen lncases=ln(day3_avg_cases)

gen casescat=day3_avg_cases
recode casescat 0/53=0 53.1/1175.9=1 1176/250000=2

**DEMOGRAPHICS (with Political Knowledge)
label define agelab 1 "Under 18" 2 "18-24" 3 "25-34" 4 "35-50" 5 "51-65" 6 ">65"
label values age agelab

gen race5=race
recode race5 1=1 2=2 3=3 4=4 5=0 6=0
label define race5lab 0 "Other" 1 "White" 2 "African American" 3 "Asian American" 4 "Hispanic/Latino" 
label values race5 race5lab

gen female = gender
recode female 1/1 = 0 2/2 = 1 3/4 = 0

recode education 1=0 2=1 3=2 6=2 4=3 5=4


replace education=education/4
replace income=(income-1)/4

gen p_knowledge_vetob  = p_knowledge_veto
gen p_knowledge_hofrb = p_knowledge_hofr
gen p_knowledge_constitutionb  = p_knowledge_constitution
gen p_knowledge_vpb = p_knowledge_vp
gen p_knowledge_conservativeb  = p_knowledge_conservative
recode p_knowledge_vetob 0/3 = 0 4/4 = 1 5/6 = 0 ./. = 0
recode p_knowledge_hofrb 1/1 = 1 2/4 = 0 ./. = 0
recode p_knowledge_constitutionb 1/2 = 0 3/3 = 1 4/4 = 0 ./. = 0
recode p_knowledge_vpb 1/2 = 0 3/3 = 1 4/5= 0 ./. = 0
recode p_knowledge_conservativeb 1/1 = 0 2/2 = 1 3/4 = 0 ./. = 0
gen poliknow = (p_knowledge_vetob + p_knowledge_hofrb + p_knowledge_constitutionb + p_knowledge_vpb + p_knowledge_conservativeb)/5
sum poliknow if  wave2pid !=4 



**COVID CONTROLS
**Anyone in House Maybe Had It
gen respondcv=.
replace respondcv=0 if perscv==1 
replace respondcv=0 if perscv==2 & perscvnslikely==1
replace respondcv=0 if perscv==2 & perscvnslikely==2
replace respondcv=1 if perscv==2 & perscvnslikely==3
replace respondcv=1 if perscv==2 & perscvnslikely==4
replace respondcv=1 if perscv==3
replace respondcv=1 if perscv==4
replace respondcv=1 if perscv==5
 
gen roommatecv=.
replace roommatecv=. if housecv==1
replace roommatecv=0 if housecv==2
replace roommatecv=0 if housecv==3 & housecvnslikely==1
replace roommatecv=0 if housecv==3 & housecvnslikely==2
replace roommatecv=1 if housecv==3 & housecvnslikely==3
replace roommatecv=1 if housecv==3 & housecvnslikely==4

replace roommatecv=1 if housecv==4
replace roommatecv=1 if housecv==5
replace roommatecv=1 if housecv==6


gen hhcovid=.
replace hhcovid=1 if respondcv==1 | roommatecv==1
replace hhcovid=0 if respondcv==0 & roommatecv==0
replace hhcovid=0 if respondcv==0 & roommatecv==.


*Risk of getting or suffering
gen workoffice = workleavehome
recode workoffice 1/1 = 0 2/4 = 1
recode workoffice ./. = 0 if laidoff < 3
gen househealthb = househealhcare
recode househealthb 1/1 = 0 2/2 =1
gen childunder4b = childunder4
recode childunder4b 1/1 = 0 2/2 =1
gen pregnantb = pregnant
recode pregnantb 1/1 = 0 2/2 =1
gen riskhealthb = riskhealth
recode riskhealthb 1/1 = 0 2/2 =1 

gen agerisk = age
recode agerisk 1/5 = 0 6/6 = 1

*risk of bad illness
gen risksick0 = riskhealthb + childunder4b + pregnantb
gen risksick = risksick0
recode risksick 0/0 = 0 1/3 = 1

**Economic Problems
gen workout = 0
 recode workout 0/0 = 1 if workleavehome != . & workleavehome > 1

replace cvincomefuture=(cvincomefuture-1)/4
 
replace difficultnocontact=(difficultnocontact)/100
 
 
 *ISSUE POSITIONS AND IDENTITY CONTROLS
replace soc_sec_spending=(soc_sec_spending-1)/2
replace healthcare=(healthcare-1)/6
replace services_spending=(services_spending-1)/6 
replace gov_role=(gov_role-1)/6 
replace abortion=(abortion-1)/4
replace homosexual_protection=(homosexual_protection-1)/4
replace mmigration=(mmigration-1)/6 
replace trans_protection=(trans_protection-1)/4

alpha soc_sec_spending healthcare services_spending gov_role abortion homosexual_protection mmigration trans_protection

gen issues01=(soc_sec_spending+healthcare+services_spending+gov_role+abortion+homosexual_protection+mmigration+trans_protection)/8
gen partyident=((party_importance-1)/4+(party_describe-1)/4+(party_wethey-1)/4+(party_extent-1)/4)/4

replace djtpct=djtpct/100

gen w1ideology01=(wave1ideology-1)/6

replace political_interest=(political_interest-1)/4

**WHERE THEY GET INFORMATION
gen tvnews_fox2 = tvnews_fox
recode tvnews_fox2 1/1 = 1 2/2 = 0

gen tvnews_cnn2 = tvnews_cnn
recode tvnews_cnn2 1/1 = 1 2/2 = 0

gen tvnews_msnbc2 = tvnews_msnbc
recode tvnews_msnbc2 1/1 = 1 2/2 = 0

gen natlnewspaper=0 
replace natlnewspaper=1 if newspaper_nyt==1 | newspaper_washpost==1
replace natlnewspaper=. if newspaper_nyt==. & newspaper_washpost==.

gen networknews=0
replace networknews=1 if tvnews_nbc==1 | tvnews_abc==1 | tvnews_cbs==1
replace networknews=. if tvnews_nbc==. & tvnews_abc==. & tvnews_cbs==.

gen localtvnews2 = tvnews_local
recode localtvnews2 1/1 = 1 2/2 = 0

gen socialmedia=0 if social_freq<5
replace socialmedia=0 if social_news==1
replace socialmedia=0.333333 if social_news==2
replace socialmedia=0.666667 if social_news==3
replace socialmedia=1 if social_news==4

gen trumppress01=cvtrumppress
recode trumppress01 1=0 2=.3333333 3=.6666667 4=1 5=1
                       
label define condlab 1 "T=N S=N" 2 "T=R S=N" 3 "T=O S=N" 4 "T=F S=N" 5 "T=N S=M" 6 "T=R S=M" 7 "T=O S=M" 8 "T=F S=M" 9 "T=N S=S" 10 "T=R S=S" 11 "T=O S=S" 12 "T=F S=S" 13 "No Pol Qs"
label values condition2 condlab

gen talkcond=condition2 
recode talkcond 1=0 2=1 3=2 4=3 5=0 6=1 7=2 8=3 9=0 10=1 11=2 12=3 13=.

gen sortcond=condition2 
recode sortcond 1=0 2=0 3=0 4=0 5=1 6=1 7=1 8=1 9=2 10=2 11=2 12=2 13=.


cls
**Models
**Worry
**Model for Figure 3
regr worry i.republican##c.negparty c.lncases c.countypopmil  i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
margins, dydx(negparty) at(republican=(0 1))
margins, dydx(republican) at(negparty=(0(.1)1))
regr worry i.republican##c.negparty##c.lncases c.countypopmil  i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
regr worry  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13
regr worry  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
regr worry  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.republican##c.trumppress01 i.tvnews_fox2 i.tvnews_cnn2 i.tvnews_msnbc2 i.natlnewspaper i.networknews i.localtvnews2 c.socialmedia i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
**Model for Figure 4 and Figure 7
regr worry  i.republican##c.negparty##c.lncases i.republican##c.allin##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.republican##c.trumppress01 i.tvnews_fox2 i.tvnews_cnn2 i.tvnews_msnbc2 i.natlnewspaper i.networknews i.localtvnews2 c.socialmedia i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
margins, dydx(republican) at(negparty=(0(.05)1) lncase=(3.97 7.07))
margins, dydx(negparty) at(republican=(0 1) lncases=(3.97 7.07))

**Behavior 
**Model for Figure 3
regr covidbehavior i.republican##c.negparty c.lncases c.countypopmil  i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
margins, dydx(negparty) at(republican=(0 1))
margins, dydx(republican) at(negparty=(0(.1)1))
regr covidbehavior i.republican##c.negparty##c.lncases c.countypopmil  i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
regr covidbehavior  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13
regr covidbehavior  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
regr covidbehavior  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.republican##c.trumppress01 i.tvnews_fox2 i.tvnews_cnn2 i.tvnews_msnbc2 i.natlnewspaper i.networknews i.localtvnews2 c.socialmedia i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
**Model for Figure 5 and Figure 7
regr covidbehavior  i.republican##c.negparty##c.lncases i.republican##c.allin##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.republican##c.trumppress01 i.tvnews_fox2 i.tvnews_cnn2 i.tvnews_msnbc2 i.natlnewspaper i.networknews i.localtvnews2 c.socialmedia i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
margins, dydx(republican) at(negparty=(0(.05)1) lncase=(3.97 7.07))
margins, dydx(negparty) at(republican=(0 1) lncases=(3.97 7.07))

**Policy 
**Model for Figure 3
regr covidpolicy i.republican##c.negparty c.lncases c.countypopmil  i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
margins, dydx(negparty) at(republican=(0 1))
margins, dydx(republican) at(negparty=(0(.1)1))
regr covidpolicy i.republican##c.negparty##c.lncases c.countypopmil  i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
regr covidpolicy  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13
regr covidpolicy  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
regr covidpolicy  i.republican##c.negparty##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.republican##c.trumppress01 i.tvnews_fox2 i.tvnews_cnn2 i.tvnews_msnbc2 i.natlnewspaper i.networknews i.localtvnews2 c.socialmedia i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
**Model for Figure 6 and Figure 7
regr covidpolicy  i.republican##c.negparty##c.lncases i.republican##c.allin##c.lncases c.countypopmil i.hhcovid i.risksick i.workout c.cvincomefuture c.difficultnocontact i.age i.female i.race5 c.education  c.income i.repgov i.republican##c.djtpct i.republican##c.partyident i.republican##c.w1ideology01 i.republican##c.issues01  i.republican##c.political_interest i.republican##c.poliknow i.republican##c.trumppress01 i.tvnews_fox2 i.tvnews_cnn2 i.tvnews_msnbc2 i.natlnewspaper i.networknews i.localtvnews2 c.socialmedia i.talkcond##i.sortcond if wave2pid!=4 & condition2!=13, cluster(fips)
margins, dydx(republican) at(negparty=(0(.05)1) lncase=(3.97 7.07))
margins, dydx(negparty) at(republican=(0 1) lncases=(3.97 7.07))
